package com.pi.shisan.service.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {

    private int code;

    private String msg;

    private T data;

    public static <T>Result<T> ok() {
        return new Result<>(1,"操作成功",null);
    }

    public static <T>Result<T> ok(T data) {
        return new Result<>(1,"操作成功",data);
    }
    public static <T>Result<T> err(String msg) {
        return new Result<>(0,msg,null);
    }

    public static <T>Result<T> err(int code, String msg) {
        return new Result<>(code,msg,null);
    }
    public static <T>Result<T> err(int code, String msg, T data) {
        return new Result<>(code,msg,data);
    }
}
